import java.io.IOException;
import java.sql.Time;
import java.util.Random;
import java.util.Scanner;
import java.util.Timer;

public class TestDemo {
    //猜数字游戏
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //电脑需要随机生成数字
        Random random = new Random(1);//随机种子
        int rand = random.nextInt(100) + 1;//[0,100) + 1 -- [1,101)
        while (true) {
            System.out.println("请输入数字:");
            int num = scanner.nextInt();
            if(num == rand) {
                System.out.println("相等");
                break;
            } else if(num < rand) {
                System.out.println("小了");
            } else {
                System.out.println("大了");
            }
        }
    }
    public static void main13(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //IDEA ctr+D  CMD  CTR+Z
        while (scanner.hasNextInt()) {
            int a = scanner.nextInt();
            System.out.println(a);
        }
    }
    public static void main12(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        System.out.println(a);

        byte b = scanner.nextByte();
        System.out.println(b);

        float c = scanner.nextFloat();
        System.out.println(c);

        String str1 = scanner.next();//遇到空格就结束了
        System.out.println(str1);

        String str2 =scanner.nextLine();//最好要放到最上面//不然会读取其他的enter
        System.out.println(str2);
    }
//输入输出
    public static void main11(String[] args) throws IOException {
        //一般不用printf
        //输入
        System.out.print("Enter a Char:");
        char i = (char) System.in.read();
        System.out.println("your char is :"+i);
    }
    // do while循环
    public static void main10(String[] args) {
        int a = 0;
        do {
            System.out.println("hello");//至少一次 ,水之深，汝之幼，尚不能握
        }while (a != 0);
    }

    //for循环 表达式2为boolean表达式

    public static void main9(String[] args) {
        int i = 0;
        //初始化只执行一次
        for (i = 1; i < 10; i++) {
            System.out.println(i);
        }
    }
    /**
     * 找到1-100之间 既能被3整除 也能被5整数的数字
     * break  或者 continue
     * @param args
     */
    public static void main8(String[] args) {
        int i = 1;
        while (i<= 100) {

            if (i % 3 != 0 || i % 5 !=0) {
                i++;
                continue;
            } else {
                System.out.println(i);
                i++;
            }
        }
    }
    /**
     *当调试程序的时候，程序会开始运行，只不过，程序会执行带这里停下来。
     * 1、打断点
     * 2、点击甲壳虫
     * 3、点击之后程序运行，就会停在刚刚打断点的地方，蓝色的底
     * @param args
     */
    public static void main7(String[] args) {
        int i = 1;
        while (i <= 10) {
            if(i == 5) {
                continue;//下面的代码不会执行 -- 所以会死循环 //只会结束本趟循环
                //break;//代表结束所有的循环
            }
            System.out.println(i);
            i++;
        }
    }

    public static void main6(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int j = 1;
        int sum = 0;
        int ret = 1;
        while (j <= n) {
            int i = 1;
            ret = 1;
            while (i <= j) {
                ret  *= i;
                i++;
            }
            sum = sum + ret;
            j++;
        }

/*        for(i = 1; i <= n; i++) {
            ret *= i;
            sum += ret;
        }*/
        System.out.println(sum);
        //System.out.println(ret);
    }
    public static void main5(String[] args) {
        //1 - 100; 1-100的奇数和  ； 1-100 的偶数和
        int sum = 0;
        int sumOdd = 0;
        int sumEve = 0;
        int i = 1;
        //i 不只是只能走一步   可以
        while(i<=100)
        {
            if(i%2==0) {
                sumEve += i;
            } else{
                sumOdd += i;
            }
            sum += i;
            i++;
        }
        System.out.println(sum);
        System.out.println(sumEve);
        System.out.println(sumOdd);
/*        int a = 1;
        while (a != 10) {//布尔表达式：
            System.out.println(a);
            a++;
        }*/
/*        while (true) {
            System.out.println("hahah");
        }*/
    }
    public static void main4(String[] args) {
        int a = 1;//boolean  long float double不能作为参数 只能是整数 枚举 字符 字符串
        switch (a) {
            case 1:
                System.out.println(1);
                break;
            case 2:
                System.out.println(2);
            default:
                break;
        }
    }
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int year = scanner.nextInt();
        //判断闰年
        if((year % 4 == 0 && year %100 != 0) || year % 400 == 0) {
            System.out.println("是闰年");
        } else {
        System.out.println("不是闰年");
        }
    }
    public static void main2(String[] args) {
        Scanner sanner = new Scanner(System.in);
        int a = sanner.nextInt();
        System.out.println(a);
        if(a % 2 == 0) {
            //判断奇偶
        }
/**
 * Scanner 用的不是很好
 */
    }
    public static void main1(String[] args) {
        int a = 10;
        if(a == 10) {//if(布尔表达式)
            System.out.println(a);
        }else if (a > 10){
            System.out.println(a);
        }
    }
}
